-----------------------------------	
-- Area: Valkurm Dunes	
-- NPC:  Field Manual	
-----------------------------------	
	
require("/scripts/globals/settings");	
require("/scripts/globals/fieldsofvalor");	
require("scripts/globals/keyitems");
	
-----------------------------------	
-- onTrigger Action	
-----------------------------------	
	

function onTrigger(player,npc)
--17199750 mog tablet
--17199752 planer ortex
	local npc = GetNPCByID(17199750); --npcid
	local game1 = player:getVar("mishimove"); -- move step
	local game2 = player:getVar("spammy"); -- move step
	local  Randx = math.random(-20,20)
--6543 Yay! let's keep at it!≺Prompt≻ 
	if(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") == 1) then-- has moogle key  move NPC
	 player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6543);
	elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") == 2)   then-- has moogle key  move NPC
	player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6540);
	elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") == 3)   then-- has moogle key  move NPC
	player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6524);
    elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") == 4)   then-- has moogle key  move NPC
	player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6534);
	elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") == 5)   then-- has moogle key  move NPC
	player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6537);
    elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") == 6)  then-- has moogle key  move NPC
	player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6440);
	elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") >= 7) and (player:getVar("spammy") <=10)   then-- has moogle key  move NPC
	player:setVar("spammy", player:getVar("spammy") + 1)
    npc:setAnimation(0)
	npc:setPos(player:getXPos() +Randx,player:getYPos()+8,player:getZPos()+ Randx,270);
	player:messageSpecial(6566);
	elseif(player:hasKeyItem(MOOGLE_KEY) == false) and (player:getVar("spammy") > 10) then
	player:setVar("spammy",1);
	--npc:setPos(player:getXPos(),player:getYPos(),player:getZPos());
	npc:setPos(-208,0,-50);	
	player:messageSpecial(11235);
	end
end;	

	
-----------------------------------	
-- onTrade Action	
-----------------------------------	
	
function onTrade(player,npc,trade)
	local npc = GetNPCByID(17199750); -- mog-tablet
		if (trade:hasItemQty(6403,1) and (player:hasKeyItem(MOOGLE_KEY) == false)) then -- donko trade I want key item
			player:addKeyItem(MOOGLE_KEY);
		    player:setVar("mishimove",1);
			player:messageSpecial(6394,1184);
			player:messageSpecial(6403,537);		
		elseif (trade:hasItemQty(6403,1) and (player:hasKeyItem(MOOGLE_KEY) == true)) then -- donko trade I want key item
			player:delKeyItem(MOOGLE_KEY);
			player:messageSpecial(6395,1184); 
			player:messageSpecial(6403,537);
		elseif (trade:hasItemQty(268,1) and player:getVar("mishimove")== 28) then 
		--SpawnMob(17199438,300):updateEnmity(player); -- spawn hobgoblin beastmaster
		player:messageSpecial(6657);		
		player:tradeComplete(trade);
		player:setVar("mishimove",1);
		npc:setPos(-208,0,-50);	
		end
		if (trade:hasItemQty(537,1)) then
				SpawnMob(17199438,300):updateEnmity(player); -- spawn VE
				player:tradeComplete(trade);		
end				
end;	
	
-----------------------------------	
-- onEventSelection	
-----------------------------------	
	
function onEventUpdate(player,csid,menuchoice)	
	updateFov(player,csid,menuchoice,7,8,9,10,57);
end;	
	
-----------------------------------	
-- onEventFinish Action	
-----------------------------------	
	
function onEventFinish(player,csid,option)	
	finishFov(player,csid,option,7,8,9,10,57,FOV_MSG_VALKURM);
end;	
